const values_default = {}

const domain_default = {}

const fields_default = {
  company_id: null,
  name: null,
  department_id: null,
  job_id: null,
  barcode: null,
  user_id: null
}

const filterItems = [
  { type: 'input', name: 'name___like', placeholder: '姓名' },
  { type: 'select', name: 'department_id', placeholder: '选择部门' }
]

const columns = [
  { name: 'company_id__name', type: 'char', label: '公司' },
  { name: 'barcode', type: 'char', label: '工号' },
  { name: 'name', type: 'char', label: '姓名' },
  { name: 'department_id__name', type: 'char', label: '部门' },
  { name: 'job_id__name', type: 'char', label: '职位' },
  { name: 'user_id__name', type: 'char', label: '登录用户' }
]

const formItems = [
  { type: 'input', name: 'name', label: '姓名' },
  { type: 'input', name: 'barcode', rules: { required: false }, label: '工号' },
  {
    type: 'select',
    name: 'department_id',
    label: '部门',
    rules: { required: false },
    placeholder: '选择部门'
  },
  {
    type: 'select',
    name: 'job_id',
    label: '职位',
    rules: { required: false },
    placeholder: '选择职位'
  },
  {
    type: 'select',
    name: 'user_id',
    label: '登录用户',
    rules: { required: false },
    placeholder: '登录用户'
  }
]

const Model = {
  configs: {
    values_default,
    domain_default,
    fields_default,
    columns,
    filterItems,
    formItems
  },

  extend: BaseClass => {
    class ModelClass extends BaseClass {
      global_domain(domain_src = {}) {
        const domain = { ...domain_src }
        // const userinfo = self.get_userinfo()
        // const { uid } = userinfo
        // domain.user_id = uid
        return super.global_domain(domain)
      }
    }
    return ModelClass
  }
}

export default Model
